a34e5a9153cb330432e251249d391947becd8cab,src/net/java/sip/communicator/impl/gui/main/chat/toolBars/EditTextToolBar.java,EditTextToolBar,selectColor,#Object#JLabel#,442

Before Change


        // use the style of the character preceding the carret
        AttributeSet attributes =
            ((HTMLDocument) chatEditorPane.getDocument())
                .getCharacterElement(index - 1).getAttributes();

        if (attributes.getAttribute(styleConstant) != null)
        {

After Change


        if (chatEditorPane.getSelectedText() == null)
        {
            int index = chatEditorPane.getCaretPosition();
            selectedAttribute =
                ((HTMLDocument) chatEditorPane.getDocument())
                    .getCharacterElement(index - 1).getAttributes()
                    .getAttribute(styleConstant);
        }
        else
        {
            for (int index = chatEditorPane.getSelectionStart();
                index < chatEditorPane.getSelectionEnd(); index++)
            {
                AttributeSet attributes =
                    ((HTMLDocument) chatEditorPane.getDocument())
                        .getCharacterElement(index).getAttributes();

                if (attributes.getAttribute(styleConstant) != null)
                    selectedAttribute = attributes.getAttribute(styleConstant);
            }
        }

        if (selectedAttribute != null)
            colorLabel.setBackground((Color)selectedAttribute);
        else
            colorLabel.setBackground(Color.BLACK);